unit frmOrder;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
  FMX.Objects, FMX.StdCtrls, FMX.TabControl, FMX.Edit, FMX.ExtCtrls, FMX.Media,
  Data.Bind.EngExt, Fmx.Bind.DBEngExt, Data.Bind.Components;

type
  TfrmMain = class(TForm)
    StyleBookDefault: TStyleBook;
    LayoutMain: TLayout;
    TabControlOrder: TTabControl;
    TabItem: TTabItem;
    TabPurchase: TTabItem;
    TabPromotion: TTabItem;
    TabPayment: TTabItem;
    TabBill: TTabItem;
    LayoutHeader: TLayout;
    LayoutFooter: TLayout;
    LayoutContent: TLayout;
    LayoutBarcode: TLayout;
    LayoutPurchaseItem: TLayout;
    LayoutTabItemTool: TLayout;
    LayoutTabItem: TLayout;
    LayoutBarcodeText: TLayout;
    LayoutBarcodeReader: TLayout;
    LabelBarcode: TLabel;
    LayoutBarcodeTextCenter: TLayout;
    TextBarcode: TEdit;
    ImageBarcodeReader: TImage;
    CameraComponent1: TCameraComponent;
    LayoutPurchaseAction: TLayout;
    ButtonPurchase: TButton;
    ButtonCancel: TButton;
    LayoutPurchaseForm: TLayout;
    ButtonSeting: TButton;
    ButtonBack: TButton;
    Label1: TLabel;
    LayoutPurchase: TLayout;
    LabelPurchaseMoney: TLabel;
    LabelPurchaseCurrency: TLabel;
    LayoutDetailPurchase: TLayout;
    LayoutDetailDiscount: TLayout;
    LabelDetailPurchaseHeader: TLabel;
    LabelDetailPurchaseCurrency: TLabel;
    LabelDetailPurchaseMoney: TLabel;
    LabelDetailDiscountHeader: TLabel;
    LabelDetailDiscountMoney: TLabel;
    LabelDetailDiscountCurrency: TLabel;
    LayoutPurchaseDetail: TLayout;
    procedure frmMain_onResize(Sender: TObject);
    procedure frmMain_onShow(Sender: TObject);
    procedure frmMain_onCreate(Sender: TObject);
    procedure frmMain_onActivate(Sender: TObject);

  private
    { Private declarations }
  public
    layoutHeight: TLayout;
    layoutWidth: TLayout;
  end;

var
  frmMain: TfrmMain;
  PanelMain: TPanel;

implementation

{$R *.fmx}

procedure TfrmMain.frmMain_onActivate(Sender: TObject);
begin
  {showMessage('Activate Event');}
end;

procedure TfrmMain.frmMain_onCreate(Sender: TObject);
begin
  {showMessage('Create Event');}

  {layoutHeight.Align := TAlignLayout.Top;
  layoutHeight.Children.Items.AddObject(Panel1);

  {
  layoutHeight := Layout.Client([
    Layout.Client(Panel1),
    Layout.Right(Layout.Width(140),
      Layout.Top(Layout.Stretch, [Panel2, Panel3, Panel4]))
  ]);
  {
  FLayoutLandscape :=
  Layout.Client([
    Layout.Client(Panel1),
    Layout.Right(Layout.Width(140),
      Layout.Top(Layout.Stretch, [Panel2, Panel3, Panel4]))
  ]);
  }

end;

procedure TfrmMain.frmMain_onResize(Sender: TObject);
begin
  if frmMain.Width < frmMain.Height then
  begin
    LayoutPurchaseItem.Align := TAlignLayout.Bottom;
    LayoutPurchaseItem.Height := (LayoutTabItem.Height - LayoutTabItemTool.Height) * 0.6;
    LayoutPurchaseDetail.Width := LayoutFooter.Width * 0.4;
    LayoutDetailPurchase.Width := LayoutFooter.Width * 0.4;
    LayoutDetailDiscount.Width := LayoutFooter.Width * 0.4;
  end
  else
  begin
    LayoutPurchaseItem.Align := TAlignLayout.Right;
    LayoutPurchaseItem.Width := LayoutTabItem.Width * 0.4;
    LayoutPurchaseDetail.Width := LayoutFooter.Width * 0.3;
  end;
  LayoutTabItemTool.Visible := false;
  LayoutBarcodeTextCenter.Width := LayoutBarcodeText.Width * 0.8;
  ButtonPurchase.Width := LayoutPurchaseForm.Width *0.5;
end;

procedure TfrmMain.frmMain_onShow(Sender: TObject);
begin
  {showMessage('Show Event')}
end;

end.
